package com.firemoss.atonement.changewatcher.valuecomparison
{
	import mx.collections.IList;

	public class ListComparitor extends AbstractComparitor implements IValueComparitor
	{
		public function ListComparitor()
		{
		}
		
		public function compare(originalValue:*, newValue:*):*
		{
			if ( originalValue is IList && newValue is IList )
			{
				var orig : IList = originalValue as IList
				var newVal : IList = newValue as IList
					
				if ( orig != null && newVal != null )
				{
					for ( var i:int = 0; i < orig.length; i++ )
					{
						if ( i > newVal.length - 1 )
						{
							return newVal
						}
						else if ( compareNestedValues( orig[i], newVal[i] ) != null )
						{
							return newVal
						}
					}
				}
				else if ( newVal != null )
				{
					return newVal
				}
				else
				{
					return null
				}
			}
			
			return null
		}
	}
}